package com.shop.shoppingmall.controller;

import com.shop.shoppingmall.entity.ShProductComment;
import com.shop.shoppingmall.service.ShProductCommentService;
import com.shop.shoppingmall.util.api.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 商品评论表(ShProductComment)表控制层
 *
 * @author makejava
 * @since 2020-09-07 17:09:35
 */
@RestController
@RequestMapping("shProductComment")
@CrossOrigin
public class ShProductCommentController {
    /**
     * 服务对象
     */
    @Resource
    private ShProductCommentService shProductCommentService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public ShProductComment selectOne(String id) {
        return this.shProductCommentService.queryById(id);
    }

    @PostMapping("/insertComment")
    public Result insertComment(@RequestBody ShProductComment shProductComment){
        return shProductCommentService.insert(shProductComment);
    }

    /**
     * 展示该用户的所有的评价
     * @param request
     * @return
     */
    @GetMapping("/selectCommentByUserId")
    public Result selectCommentByUserId(HttpServletRequest request){
        return shProductCommentService.selectCommentByUserId(request);
    }

    /**
     * 查询该商品的所有的评论
     * @param productId
     * @return
     */
    @GetMapping("/selectCommentAll")
    public Result selectCommentAll(String productId){
        return shProductCommentService.selectCommentAll(productId);
    }

    @PostMapping("/updateCommentStatus")
    public Result updateCommentStatus(){
        return shProductCommentService.updateCommentStatus();
    }

}
